using System.Collections;
using System.Collections.Generic;

namespace NFreeMarker.Template.Utility
{
    public static class DictionaryExtensions
    {
        public static TValue GetValueOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> self, TKey key)
        {
            TValue value;
            self.TryGetValue(key, out value);
            return value;
        }

        public static object GetValueOrDefault(this IDictionary self, object key)
        {
            return self.Contains(key)
                ? self[key]
                : null;
        }
    }
}